﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WinApp.i18n;

namespace WinApp.View
{
    public partial class MyExams : UIPage
    {
        public ExamList _examListIncomplete { get; set; }

        public ExamList _examListWaitingForRetake { get; set; }

        public ExamList _examListWaitingForGrading { get; set; }

        public ExamList _examListCompleted { get; set; }

        public ExamList _examListAll { get; set; }

        public MyExams()
        {
            InitializeComponent();
            this.Text = Language.GetLang("myExams");

            tabPage1.Text = Language.GetLang("incomplete");
            if (_examListIncomplete == null)
                _examListIncomplete = new ExamList();
            _examListIncomplete.Dock = DockStyle.Fill;
            tabPage1.Controls.Add(_examListIncomplete);

            tabPage2.Text = Language.GetLang("waitingForRetake");
            if (_examListWaitingForRetake == null)
                _examListWaitingForRetake = new ExamList();
            _examListWaitingForRetake.Dock = DockStyle.Fill;
            tabPage2.Controls.Add(_examListWaitingForRetake);

            tabPage3.Text = Language.GetLang("waitingForGrading");
            if (_examListWaitingForGrading == null)
                _examListWaitingForGrading = new ExamList();
            _examListWaitingForGrading.Dock = DockStyle.Fill;
            tabPage3.Controls.Add(_examListWaitingForGrading);

            tabPage4.Text = Language.GetLang("completed");
            if (_examListCompleted == null)
                _examListCompleted = new ExamList();
            _examListCompleted.Dock = DockStyle.Fill;
            tabPage4.Controls.Add(_examListCompleted);

            tabPage5.Text = Language.GetLang("all");
            if (_examListAll == null)
                _examListAll = new ExamList();
            _examListAll.Dock = DockStyle.Fill;
            tabPage5.Controls.Add(_examListAll);
        }

        private void MyExams_Load(object sender, EventArgs e)
        {
            //默认打开第一个tabPage,并且查询
            uiTabControl1.SelectTab(0);
            _examListIncomplete._SearchMyExaminationEntity.LastStatuArr = new int[] { 1, 2, 6 };
            _examListIncomplete.LoadPanellData();
        }

        private void uiTabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            var tabControl = sender as TabControl;
            var currentPage = tabControl.SelectedTab;

            switch (tabControl.SelectedIndex)
            {
                case 0:
                    _examListIncomplete._SearchMyExaminationEntity.LastStatuArr = new int[] { 1, 2, 6 };
                    _examListIncomplete.LoadPanellData();
                    break;
                case 1:
                    _examListWaitingForRetake._SearchMyExaminationEntity.LastStatuArr = new int[] { 5 };
                    _examListWaitingForRetake.LoadPanellData();
                    break;
                case 2:
                    _examListWaitingForGrading._SearchMyExaminationEntity.LastStatuArr = new int[] { 7 };
                    _examListWaitingForGrading.LoadPanellData();
                    break;
                case 3:
                    _examListCompleted._SearchMyExaminationEntity.LastStatuArr = new int[] { 3, 4 };
                    _examListCompleted.LoadPanellData();
                    break;
                case 4:
                    _examListAll._SearchMyExaminationEntity.LastStatuArr = new int[] { };
                    _examListAll.LoadPanellData();
                    break;
                default:
                    break;
            }
        }
    }
}
